//
//  ZDOrderCell.m
//  ZDPension
//
//  Created by 刘甲奇 on 2017/6/19.
//  Copyright © 2017年 maker. All rights reserved.
//

#import "ZDOrderCell.h"
#import "MakerTools.h"
#import "UIImageView+WebCache.h"

@interface ZDOrderCell()

@property (weak, nonatomic) IBOutlet UILabel *storeNameLabel;
@property (weak, nonatomic) IBOutlet UIImageView *consumeTypeIcon;
@property (weak, nonatomic) IBOutlet UILabel *orderNumberLabel;
@property (weak, nonatomic) IBOutlet UILabel *timerLabel;
@property (weak, nonatomic) IBOutlet UIImageView *icon;
@property (weak, nonatomic) IBOutlet UILabel *goodsNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *goodsPriceLabel;
@property (weak, nonatomic) IBOutlet UILabel *goodsNumberLabel;
@property (weak, nonatomic) IBOutlet UILabel *goodsTotalLabel;
@property (weak, nonatomic) IBOutlet UIView *bottonView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *buttonViewHeight;
@property (weak, nonatomic) IBOutlet UIButton *payButton;
@property (weak, nonatomic) IBOutlet UIButton *cancelButton;


@end


@implementation ZDOrderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.payButton.layer.borderWidth = 1;
    self.payButton.layer.borderColor = LEHaxColor(0xc8c8c8).CGColor;
    self.cancelButton.layer.borderWidth = 1;
    self.cancelButton.layer.borderColor = LEHaxColor(0xc8c8c8).CGColor;
}

- (void)setModel:(ZDOrderModel *)model
{
    _model = model;
    self.storeNameLabel.text = model.store_name;
    self.orderNumberLabel.text = [NSString stringWithFormat:@"订单号: %@",model.order_sn];
    self.timerLabel.text = [MakerTools getFormatTime:model.add_time];
    UIImage *image = [model.door_service isEqualToString:@"1"] ? [UIImage imageNamed:@"smfw"] : [UIImage imageNamed:@"ddxf"];
    self.consumeTypeIcon.image = image;
    self.goodsTotalLabel.text = [NSString stringWithFormat:@"共计: %@",model.order_amount];
    
    ZDGoodsDetailModel *goodsModel = model.extend_order_goods[0];
    [self.icon sd_setImageWithURL:[NSURL URLWithString:goodsModel.goods_image_url] placeholderImage:[UIImage imageNamed:@"zwt"]];
    self.goodsNameLabel.text = goodsModel.goods_name;
    self.goodsPriceLabel.text = [NSString stringWithFormat:@"¥:%@",goodsModel.goods_price];
    self.goodsNumberLabel.text = [NSString stringWithFormat:@"x %@",goodsModel.goods_num];
    
}
- (void)setOrdemode:(OrderMode)ordemode
{
    switch (ordemode) {
        case WaitPay:
        {
            [self.cancelButton setTitle:@"取消订单" forState:0];
            [self.payButton setTitle:@"支付" forState:0];
        }
            break;
        case WaitConsume:
        {
            self.buttonViewHeight.constant = 0;
            self.bottonView.hidden = YES;
        }
            break;
        case WaitCommit:
        {
            [self.payButton setTitle:@"去评价" forState:0];
            self.cancelButton.hidden = YES;
        }
            break;
        case Finished:
        {
            self.buttonViewHeight.constant = 0;
            self.bottonView.hidden = YES;
        }
            break;
            
        default:
            break;
    }
}
- (IBAction)payClick:(UIButton *)sender
{
    ZDLog(@"%s---%d---支付",__func__,__LINE__);
}
- (IBAction)cancelClick:(UIButton *)sender
{
    ZDLog(@"%s---%d---取消",__func__,__LINE__);
}


@end
